package com.hkd.common.api.enums;

import java.io.Serializable;

/**
 * 地域级别
 *
 * @author HKD
 * @date 2022/9/11 14:19
 */
public enum AreaType implements Serializable {
    //国家
    COUNTRY(0),
    //省份
    PROVINCE(1),
    //城市
    CITY(2),
    //地区
    AREA(3);

    private int code;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    AreaType(int code) {
        this.code = code;
    }
    public static AreaType search(int code){
        AreaType[] values = AreaType.values();
        for (AreaType value : values) {
            if (code==value.code){
                return value;
            }
        }
        return null;
    }
    public static AreaType childType(AreaType areaType){
        if (areaType==COUNTRY){
            return PROVINCE;
        }
        if (areaType==PROVINCE){
            return CITY;
        }
        if (areaType==CITY){
            return AREA;
        }
        return null;
    }
}
